const expressJwt = require('express-jwt');
const { secretKey } = require('./constant');

const jwtAuth = expressJwt({
  secret: secretKey,
  algorithms: ['HS256']
}).unless({path:[
  '/api/loginUserPass', 
  '/api/supplyDetail', 
  '/api/duplicatUsername', 
  '/api/getIdent', 
  '/api/duplicatStuNo', 
  '/api/logout',
  '/api/getImg',
  '/favicon.ico',
  '/api/uploadImg',
  '/api/uploadExcel',
  '/api/getExcel',
  '/api/saveCodeRecord',
  '/api/refindPassword',
  '/api/verify_signin'
]})

//unless 为排除那些接口,不验证Token,这里排除 '/index/load'
//注意这里的排除 为整个服务端路由,我们这里的 router/index.js 下的 /load 路由,实际是出于 /index 路由之下,详见app.js页面 app.use('/index',index) 配置

module.exports = jwtAuth;
